var start;
var end;
var step;
var items;
var varName;
var i;

function doStartTag(ctx)
{
	start = ctx.getAttribute("start") || 0;
	end = ctx.getAttribute("end");
	step = ctx.getAttribute("step") || 1;
	items = ctx.getAttribute("items");

	i = start;
	
	if(items)
	{
		if(!(items instanceof Array))
		{
			switch(typeof(items))
			{
				case "string":
				{
					items = items.split(",");
					break;
				}
				case "object":
				{
					var obj = items;
					items = [];
					for(k in obj)
					{
						items.push(k);
					}
					break;
				}
			}
		}
		end = items.length - 1;

		if(items.length == 0)
			return SKIP_BODY;
	}
	else
	{
		if(i > end)
			return SKIP_BODY;
	}
	
	
	varName = ctx.getAttribute("var");
	if(varName)
		ctx.expose(varName, items ? items[i] : i);
}

function doAfterBody(ctx)
{
	if(i < end)
	{
		i += step;

		if(varName)
			ctx.expose(varName, items ? items[i] : i);
			
		return EVAL_BODY_AGAIN;
	}
}
